from rest_framework.viewsets import ModelViewSet
from meiduo_admin.utils import MyNumbPage
from goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory
from .serializers import GoodChannelSerializer, GoodsChannelGroupSerializer, CategoriesSerializer
from rest_framework.generics import ListAPIView


class ChannelViewSet(ModelViewSet):
    serializer_class = GoodChannelSerializer
    queryset = GoodsChannel.objects.all()
    pagination_class = MyNumbPage


class ChannelTypeView(ListAPIView):
    serializer_class = GoodsChannelGroupSerializer
    queryset = GoodsChannelGroup.objects.all()


class Categories(ListAPIView):
    serializer_class = CategoriesSerializer
    queryset = GoodsCategory.objects.filter(parent=None).all()
